$(function () {

    var note = $('#note'),
        startdate = $('.starttime').text(),
        period = $('.period').text(),
        ts = new Date(startdate.replace("-", "/"));

    $('#countdown').countdown({
        timestamp: ts,
        callback: function (days, hours, minutes, seconds) {

            var message = "距离第" + "<font style='color: #FF0000;font-size: 16px;'>" + period + "</font>期还剩：" + " <br />";

            message += days + " day" + ( days == 1 ? '' : 's' ) + ", ";
            message += hours + " hour" + ( hours == 1 ? '' : 's' ) + ", ";
            message += minutes + " minute" + ( minutes == 1 ? '' : 's' ) + " and ";
            message += seconds + " second" + ( seconds == 1 ? '' : 's' ) + " <br />";

            message += "<font style='color: #ffa827;font-size: 18px;'>敬请期待!</font>";

            note.html(message);
            if (days == 0 && hours == 0 && minutes == 0 && seconds == 0) {
                location.replace(location.href)
            }
        }
    });

});
